# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=rizin
pkgver=0.4.0
pkgrel=0
pkgdesc="UNIX-like reverse engineering framework and command-line toolset"
url="https://rizin.re/"
# 32bit - 15/78 big	FAIL 0.26s (exit status 1)
# Could be integer overflow
# s390x:
# 49/75 pdb FAIL 0.97s (exit status 1)
# 55/75 serialize_analysis FAIL 0.03s (exit status 1)
options="!check" # tests are unstable
arch="all"
license="GPL-3.0-or-later AND LGPL-3.0-or-later"
makedepends="
	cmake
	meson
	py3-yaml
	capstone-dev
	file-dev
	libuv-dev
	linux-headers
	libzip-dev
	lz4-dev
	openssl-dev
	pythonispython3
	tree-sitter-dev
	xxhash-dev
	zlib-dev
	"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
source="$pkgname-$pkgver.tar.xz::https://github.com/rizinorg/rizin/releases/download/v$pkgver/rizin-src-v$pkgver.tar.xz"
builddir="$srcdir/rizin-v$pkgver"

build() {
	abuild-meson \
		-Dpackager="alpinelinux" \
		-Dpackager_version="$pkgver-r$pkgrel" \
		-Duse_sys_capstone=enabled \
		-Duse_capstone_version="v4" \
		-Duse_sys_magic=enabled \
		-Duse_sys_libzip=enabled \
		-Duse_sys_zlib=enabled \
		-Duse_sys_lz4=enabled \
		-Duse_sys_xxhash=enabled \
		-Duse_sys_openssl=enabled \
		-Duse_sys_tree_sitter=enabled \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

check() {
	# Include the build rizin otherwise
	# unit/test_rzpipe.c will fail
	export PATH="$PATH:$builddir/output/binrz/rizin/"
	meson test --no-rebuild -v -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
9d576bee48e5ceae46b4e309c53e01b82edf89a95046f576e1c38fefa73353d6d1f04e6d444332324387d4e115bc87659a358629f7277a41dfef44c82364547b  rizin-0.4.0.tar.xz
"
